package com.moco.launcher.fragment;

import com.moco.launcher.R;
import com.moco.launcher.activity.MainActivity;
import com.moco.launcher.activity.PopActivity;
import com.oazon.common.util.Blur;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

public class PauseFragment extends BaseFragment implements OnClickListener {

	private PopActivity activity = null;

	private static final String TAG = "PauseFragment";

	private Bitmap bitmap;

	public PauseFragment(Bitmap bitmap) {
		Log.d(TAG, "PauseFragment");
		this.bitmap = bitmap;
	}

	@Override
	public void onAttach(Activity activity) {
		this.activity = (PopActivity) activity;
		super.onAttach(activity);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		Log.d(TAG, "onCreateView");
		View rootView = inflater.inflate(R.layout.pause_view, container, false);
		ImageView pauseBg = (ImageView) rootView.findViewById(R.id.pause_bg);
		if (bitmap != null) {
			pauseBg.setImageBitmap(Blur.fastblur(activity, bitmap, 18));
		}
		rootView.setOnClickListener(this);
		return rootView;
	}

	@Override
	public void onClick(View v) {
		Intent intent = new Intent(activity, MainActivity.class);
		intent.putExtra("action", "play");
		activity.startActivity(intent);
		activity.finish();
		activity.overridePendingTransition(R.anim.pop_in, R.anim.pop_out);
	}
}
